Remove all-to-all operation from TSP/CP in Attention Segmentation Mask#4571
Open
dinodeep wants to merge 4 commits into
Open
Remove all-to-all operation from TSP/CP in Attention Segmentation Mask#4571dinodeep wants to merge 4 commits into
dinodeep wants to merge 4 commits into
Conversation
dinodeep
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
parambole,
richjames0,
shralex,
shuningjin,
suexu1025,
vipannalla and
xibinliu
as code owners
July 22, 2026 19:27
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When performing TSP/CP with packed sequences, the segmentation mask produced for attention from ids could introduce a large all-to-all operation (transporting bytes on the order of
O(S^2)). This PR avoids that by introducing an all-gather on the small non-broadcasted to reduce communication.More specifically, this line
would produce an all-to-all on the broadcasted
decoder_key_segment_ids[:, None, :]when running with TSP/CP sincedecoder_segment_idsis[B, S]following the input data sharding. The sequence dimension is sharded under TSP/CP constraints; however, this introduces a large all-to-all collective when constructing themask.To fix this, we add a sharding constraint on the right hand side of the equation. This all-gathers
decoder_key_segment_idson the sequence dimension for the right-hand side prior to broadcasting for a much smaller collective with the same sharded output. This reduces communication latency and can improve performance when training with large sequence lengths.Tests
I observed all-to-all operations (300-400us) in the HLO for a Llama3-70b training run executing with tensor_sequence_parallelism. Then, after running the same configuration but with the new changes, I did not observe an all-to-all instruction in the HLO, and instead, the operation was replaced with a small all-gather (30us latency).
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.